<?php

/*--------------------------------------------------------------------------------------------------
 This File contains all functions necessary for sending a request using  TringMe API's to perform
 the operations as mentioned in the documentation of the functions given below.
 
 IMPORTANT: All functions are dependent on the TringMe API function (tringmeapi.php).
--------------------------------------------------------------------------------------------------*/
require_once('tringmeapi.php');

/*--------------------------------------------------------------------------------------------------
Function Name: TringMeCreateUser                                                                     
                                                                                                      
Descripton: Create a New User                                                                         
                                                                                                     
Prototype: boolean TringMeCreateUser($email, $password, $name[,$emailsubject,$emailcontent, $referby], $result[, $private])     
                                                                                                      
Parameters:	$email- A valid Email address which will be used for login.                                     
			$password- User's password.                                             
			$name- User's name.                                                     
			$emailsubject- Subject to be included in Email.
			$emailcontent- Content to be included in Email.
			$referby-  User ID of the referenced person 
			$private-  Account Type. (optional, default is 0 = TringMe Account)                                                                   
                                                                                         
Return Values: True- When user account is Created.                                                        
			   False- If user already exists.                                                             

Side Effects: On Success Mail Send To User's Email Id For Activation.                                    
--------------------------------------------------------------------------------------------------*/

function TringMeCreateUser($email, $password, $name , $emailsubject, $emailcontent, $referby, &$result, $private=0) {
    $parameters=array();
    $parameters['op']='createuser';
    $parameters['email']=$email;
    $parameters['name']=$name;
	
	if($emailsubject!='')
		$parameters['subject']=$emailsubject;
	
	if($emailcontent!='')
		$parameters['message']=$emailcontent;
	
	if($referby!='')
		$parameters['referby']=$referby;
	    
	if($password != '')
        $parameters['pw']= $password;
    	
    if($private != 0)
        $parameters['private']=$private;
		
	$parameters['autoactivation']=0;	
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeLogin                                                                         
                                                                                                     
Descripton: Login a User                                                                             
                                                                                                     
Prototype:  boolean TringMeLogin($email, $password, $result[, $private])      
                                                                                                     
Parameters:	$email- A valid Email address which will be used for login.                                     
			$password- User's password.                                                      
			$result- Contains Cookie Information.
			$private-  Account Type. (optional, default is 0 = TringMe Account)

Return Values: True- If user is authenticated.                                                              
			   False- If user is not authenticated.                                                            

Side Effects: Cookie Set.                                                                                       
-----------------------------------------------------------------------------------------------------*/

function TringMeLogin($email, $password, &$result, $private=0){  
    $parameters=array();   
    $parameters['op']='login';
    $parameters['email']=$email;
    $parameters['pw']=$password;
		
    if($private != 0)
        $parameters['private']=$private;
    
	return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeLogout                                                                         
                                                                                                     
Descripton: Logs out a user                                                                             
                                                                                                     
Prototype:  boolean TringMeLogOut($cookie)      
                                                                                                     
Parameters: $cookie- Cookie obtained from TringMeLogin, to specify who has to be logged out

Return Values: True- If user is logged out and the associated cookie is deleted.
               False- If user cannot be logged out and hence cookie could not be deleted.
-----------------------------------------------------------------------------------------------------*/
function TringMeLogout($cookie)
{  
    $parameters=array();   
    $parameters['op']='logout';
    $parameters['cookie']=$cookie;
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeChangePassword                                                                         
                                                                                                     
Descripton: Change/Reset Password of an user.                                                                             
                                                                                                     
Prototype:  boolean TringMeChangePassword($email, $newpassword[, $private, [$oldpassword]])      
                                                                                                     
Parameters:                                                                                          
           $email- A valid Email address which will be used for login.                                     
           $newpassword- User's New password.                                                      
           $private- Account Type. (optional, default is 0 = TringMe Account)                                                                             
           $oldpassword- Users old Password(optional for resetting the password).                          

Return Values: True- If password changed.                                                              
               False- If password change fails.                                                            

Side Effects:                                                                                                  
           Change Of Password                                                                                        
-----------------------------------------------------------------------------------------------------*/
function TringMeChangePassword($email, $newpassword, $private=0, $oldpassword=""){   
	$parameters=array();    
    $parameters['op']='changepassword';
    $parameters['email']=$email;
    $parameters['pw']=$newpassword;
    
	if($oldpassword!="")
        $parameters['oldpw']=$oldpassword;
    
    if($private != 0)
        $parameters['private']=$private;
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeResetPassword                                                                         
                                                                                                     
Descripton: Change/Reset Password of an user.                                                                             
                                                                                                     
Prototype:  boolean TringMeResetPassword($email,$subject,$message)      
                                                                                                     
Parameters:                                                                                          
           $email- A valid Email address which will be used for login.                                     
           $subject- Subject of the email.                                                      
           $message- Message in the email.                                                                              

Return Values: True- If sucessful.                                                              
               False- If not successful.                                                            
-----------------------------------------------------------------------------------------------------*/
function TringMeResetPassword($email, $subject, $message, $private=0) {
	$parameters=array();
    $parameters['op']='resetpassword';
    $parameters['email']=$email;
	$parameters['subject']=$subject;
    $parameters['message']=$message;
	if($private != 0)
        $parameters['private']=$private;
    return TringMeAPI($parameters, $result);	
}


/*----------------------------------------------------------------------------------------------------
Function Name: TringMeActivateUser                                                                        
                                                                                                     
Descripton: Activates a User.                                                                             
                                                                                                     
Prototype:  boolean TringMeActivateUser($email, $code, $result,[, $private])      
                                                                                                     
Parameters:	$email- User email address.  
			$code- TringMe generated Activation Code.
			$result- response message                                   
			$private- Account Type. (optional, default is 0 = TringMe Account)
          
Return Values:	True- If activation code is valid.                                                              
				False- If activation code is not valid.                                                            
Side Effects:                                                                                                  
           None                                                                                        
-----------------------------------------------------------------------------------------------------*/

function TringMeActivateUser($email, $code, &$result, $private=0){  
    $parameters['op']='activateuser';
    $parameters['email']=$email;
    
	if($code!="")
        $parameters['activationcode']=$code;
    
   $parameters['private']=$private;
    
    return TringMeAPI($parameters,$result);
}    

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeReActivateUser                                                                        
                                                                                                     
Descripton: Re-send the activation e-mail to user.                                                                             
                                                                                                     
Prototype:  boolean TringMeReActivateUser($email[, $private])      
                                                                                                     
Parameters: $email- User email address.  
            $private- Account Type. (optional, default is 0 = TringMe Account)
                                                                                                  
Return Values:	True- If activation Code is re-sent.                                                              
				False- If activation code canot be re-sent.                                                            
                                                                                  
-----------------------------------------------------------------------------------------------------*/
function TringMeReactivateUser($email, $private=0){  
    $parameters['op']='reactivateuser';
    $parameters['email']=$email;
    
	if($private != 0)
        $parameters['private']=$private;
    
	return TringMeAPI($parameters,$result);
}    

/*----------------------------------------------------------------------------------------------------

Function Name: TringMeGetTempCookie                                                                         

Descripton: Generate a Temporary cookie with required constraints using the cookie obtained from TringMeLogin                                                                             

Prototype:  boolean TringMeGetTempCookie($result[, $cookie, $destination, $validity, $maxusage])      

Parameters:	$cookie- Session Validator.                                     
			$destnation-  If specified, the temporary cookie can be used to call specified destination only .
		    $validity- Validity of temporary cookie in minutes. Default 3 minutes.
		    $maxusage- Maximum number of call attempts. 0 For unlimited. Default 1
			$result- Contains Cookie Information.
                                                                          
Return Values: True- If user is authenticated.                                                              
			   False- If user is not authenticated.                                                            

Side Effects: Cookie Set.                                                                                       
-----------------------------------------------------------------------------------------------------*/

function TringMeGetTempCookie(&$result, $cookie="", $destination="", $validity=3, $maxusage=1){  
    $parameters=array();   
    $parameters['op']='gettempcookie';
    $cookie = trim($cookie);
    $destination = trim($destination);

    if(!empty($cookie))
        $parameters['cookie']=$cookie;

    if(!empty($destination))
        $parameters['dest']=$destination;

    if(3!=(int)$validity)
        $parameters['validity']=(int)$validity;

    if(1!=(int)$maxusage) 
        $parameters['maxusage']=$maxusage;

    return TringMeAPI($parameters, $result);

}

/*----------------------------------------------------------------------------------------------------

Function Name: TringMeDeleteTempCookie                                                                         

Descripton: Delete a Temporary cookie with required constraints using the cookie obtained from TringMeGetTempCookie.                                                                              

Prototype:  boolean TringMeDeleteTempCookie($result,$cookie,$tcookie)      

Parameters: $cookie- Session Validator.          
			$tcookie- Temporary cookie obtained from TringMeGetTempCookie API.                           
`          	$result- Contains Cookie Information.

Return Values: True- If cookie is deleted.                                                              
			   False- If cookie is not deleted.                                                            
-----------------------------------------------------------------------------------------------------*/

function TringMeDeleteTempCookie($cookie, $tcookie, &$result) {
	$parameters=array();
	$parameters['op']='deletetempcookie';
	$parameters['cookie']=trim($cookie);
	$parameters['tempcookie']=trim($tcookie);
	return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeClick2Call                                                                       
                                                                                                   
Descripton: To Establish a call between a source and a destination.                                                                             
Prototype:  boolean TringMeClick2Call($callsrc, $calldest,[, $cookie])      
                                                                                                     
Parameters:	$cookie- Session Validator..
			$callsrc- Caller's Phone Number .
			$calldest- Receiver's Phone Number.  

Return Values: True- If call is established.                                                              
               False- If call cannot be established.                                                            

Side Effects: Call Established between Caller and Receiver.                                                                                        
----------------------------------------------------------------------------------------------------*/

function TringMeClick2Call( $callsrc, $calldest,&$result,$cookie=""){   
	$parameters['op']='click2call';
    if($cookie != "") {
    	$parameters['cookie']=$cookie;
    }
	$parameters['callsrc']=$callsrc;
    $parameters['calldest']=$calldest;
	
	return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeSendSMS                                                                      
                                                                                                     
Descripton: To Send an SMS.                                                                             
                                                                                                     
Prototype:  boolean TringMeSendSMS($smsdest, $msg, $result[, $cookie])      
                                                                                                     
Parameters: $cookie- Session Validator.
			$smsdest- Recipient of Message.
			$msg- The Message.  

Return Values: True- If SMS is sent.                                                              
               False- If SMS cannot be sent.                                                            

Side Effects: Message sent to Receipient.                                                                                                                                                                                            
-----------------------------------------------------------------------------------------------------*/

function TringMeSendSMS($smsdest, $msg, &$result, $cookie="", $fromtype=0){   
	$parameters['op']='sendsms';
    if($cookie != "") {
    	$parameters['cookie']=$cookie;
    }
    $parameters['msg']=$msg;
    $parameters['fromtype']=$fromtype;
    $parameters['dest']=$smsdest;
    return TringMeAPI($parameters,$result);
}        

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeCheckRates                                                                      
                                                                                                     
Descripton: To Check Call and SMS Rates.                                                                             
                                                                                                     
Prototype:  boolean TringMeCheckRates($phoneno , $result[, $private})      
                                                                                                     
Parameters:	$phoneno- Phone Number.
			$result- Location and Rates.
			$private- Account Type. (optional, default is 0 = TringMe Account)                                                                                                 

Return Values:	True- If specified phone number is valid one to get the rates.                                                              
				False- If invalid phone number is specified.                                                            
-----------------------------------------------------------------------------------------------------*/

function TringMeCheckRates($phoneno, &$result){
	$parameters=array();
    $parameters['op']='getrate';
    $parameters['dest']=$phoneno;
        
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeGetCDR                                                                      
                                                                                                     
Descripton: To Retreive Call History.                                                                             
                                                                                                     
Prototype:  boolean TringMeGetCDR($cookie, $result[, $id, $calltag, $startdate, $enddate])     
                                                                                                     
Parameters:	$cookie- Session Validator.
			$result-  Call History. 
			$id- CDRs over this ID will be fetched. (optional, specify -1 if not to be used, has highest priority in optional parameters)
			$calltag- CDRs matching this CALLTAG will be fetched.  (optional, specify "" if not to be used, has second highest priority in optional parameters)
			$startdate- CDRs from this DATE will be fetched. (optional, specify "" if not to be used, has least priority in optional parameters)
			$enddate- CDRs untill this DATE will be fetched. (optional, used in combination with $startdate)                                                                                             

Return Values:	True- If call history is available.                                                              
				False- If Call History Does Not Present.                                                            
                                                                                   
-----------------------------------------------------------------------------------------------------*/
function TringMeGetCDR($cookie, &$result, $id=-1, $calltag="", $startdate="", $enddate=""){   
	$parameters=array();
    $parameters['op']='getcdr';
    $parameters['cookie']=$cookie;
    $parameters['json']=1;
    
	if($id!="" && $id!=-1)
        $parameters['id']=$id;
    
    elseif($calltag!="") 
		$parameters['calltag']=$calltag;
    
    elseif($startdate!=""){ 
		$parameters['startdate']=$startdate;
        $parameters['enddate']=$enddate;
    }
	
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------

Function Name: TringMeGetVoiceMails                                                                        

Descripton: Get voicemails                                                                              
                                                                                  
Prototype:  boolean TringMeGetVoiceMails($result[, $cookie, $json])      

Parameters: $cookie- Session Validator, obtained from .                                     
		    $json- If specified, result is obtained in json_encoding format.                                              
			$result- Contains Cookie Information.

Return Values: True- If VoiceMails are returned (either empty or present).                                                              
			   False- If VoiceMails are not returned.                                                            
-----------------------------------------------------------------------------------------------------*/
function TringMeGetVoiceMails($cookie, &$result) {
	$parameters=array();
    $parameters['op']='getvoicemail';
    $parameters['cookie']=$cookie;
    $parameters['json']=1;

   return TringMeAPI($parameters,$result);
}
/*-------------------------------------------------------------------------------------------------------

Function Name: TringMeDeleteVoiceMails                                                                        

Descripton: Delete voicemails                                                                              
                                                                                   
Prototype:  boolean TringMeGetVoiceMails($result[, $cookie, $vmid])      

Parameters: $cookie- Session Validator, obtained from .                           
		    $vmid- VM ID (specified in XML or json) obtained using ‘getvoicemail’, all- deletes all the voicemails.
            $result- Contains Cookie Information.

Return Values: True- If VoiceMails are deleted.                                                              
			   False- If VoiceMails are not deleted.                                                                                   
-----------------------------------------------------------------------------------------------------*/
function TringMeDeleteVoiceMails($cookie, &$result, $vmid='all') {
    $parameters=array();
    $parameters['op']='deletevoicemail';
    $parameters['cookie']=$cookie;

    if('all'==$vmid)
        $parameters['op']='deleteallvoicemails';
    else
        $parameters['vmid']=$vmid;		
   
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeGetUID                                                                       
                                                                                                     
Descripton: To Retrieve user's identification number.                                                                              
                                                                                                     
Prototype:  boolean  TringMeGetUID($email, $result[, $private])      
                                                                                                     
Parameters:	$email- A valid Email address which will be used for login.                                     
			$result- Contains UID.
			$private- Account Type. (optional, default is 0)                          

Return Values:	True- If user exists.                                                              
				False- If user doesn't exist.                                                            
-----------------------------------------------------------------------------------------------------*/
function TringMeGetUID($email, &$result, $private=0){   
	$parameters=array();
    $parameters['op']='getuid';
    $parameters['email']=$email;
    
	if($private != 0)
        $parameters['private']=$private;
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeGetUserInfo                                                                       
                                                                                                     
Descripton: Retrieve User's Information.                                                                             
                                                                                                     
Prototype:  boolean TringMeGetUserInfo($cookie, $result)      
                                                                                                     
Parameters:$cookie- Session Validator.                                     
           $result- User's Information.

Return Values: True- If cookie is valid.                                                              
               False- If cookie is not valid.                                                            
-----------------------------------------------------------------------------------------------------*/

function TringMeGetUserInfo($cookie, &$result){  
    $parameters['op']='getuser';
    $parameters['cookie']=$cookie;
	$parameters['json']=1;
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
Function Name: TringMeUpdateUserName                                                                        
                                                                                                     
Descripton: To Update User's Name.                                                                             
                                                                                                     
Prototype:  boolean TringMeUpdateUserName($cookie, $name)      
                                                                                                     
Parameters:	$cookie- Session Validator..
			$name- Edited Name.  

Return Values:                                                                                      
           True- If name is successfully updated.                                                              
           False- If name cannot be updated.                                                            

Side Effects:                                                                                                  
           User's Name Changed.                                                                                        
                                                                                                    
-----------------------------------------------------------------------------------------------------*/
function TringMeUpdateUserName($cookie, $name, &$result){  
    $parameters=array();
    $parameters['op']='setuser';
    $parameters['cookie']=$cookie;
    $parameters['name']=$name;
    return TringMeAPI($parameters,$result);

}

/*----------------------------------------------------------------------------------------------------
 * 
Function Name: TringMeUpdateReachability
                                                                                                     
Descripton: To Update Reachability of the user.                                                                             
                                                                                                     
Prototype:  boolean TringMeUpdateReachability($cookie, $connectto, $result[,$destination[, $dtmf])      
                                                                                                     
Parameters:	$cookie- Session Validator..
			$connectto- Where user will be connected when pushn-talk widget is pressed.
			$destination- User’s phone number with country code
			
Return Values: True- If successfully updated.                                                              
               False- if cannot update.                                                            

Side Effects: User's Reachability is Changed.                                                                                        
                                                                                                    
-----------------------------------------------------------------------------------------------------*/

function TringMeUpdateReachability($cookie, $connectto, &$result, $destination='', $dtmf=''){  
    $parameters=array();
    $parameters['op']='setuser';
	$parameters['cookie']=$cookie;
    $parameters['connectto']=(int) trim($connectto);

    if(''!=$destination) { 
        switch((int) trim($connectto)) {
            case 0: $parameters['phone']=trim($destination);
                    $parameters['dtmf']=trim($dtmf);
                    break;
            case 1: $parameters['gtalk']=trim($destination);
                    break;
            case 3: $parameters['sipid']=trim($destination);
                    $parameters['dtmf']=trim($dtmf);
                    break;
        }
    }

    return TringMeAPI($parameters,$result);

}
/*----------------------------------------------------------------------------------------------------
 * 
Function Name: TringMeUpdateSIPSettings                                                                      
                                                                                                     
Descripton: To Change The SIP(Session Initiated Proptocol) Setttings for making Calls.                                                                                                     

Prototype:  boolean TringMeUpdateSIPSettings($cookie, $proxy, $user, $pass, $result[,$auth])     
                                                                                                     
Parameters:                                                                                          
           $cookie- Session Validator.                             
           $proxy- The SIP Proxy Server Settings .
           $user- SIP User Name.
           $pass- SIP Authentication Password.
           $auth- SIP Auth Name [Optional].                                                                                                 

Return Values: True- If SIP settings were updated.                                                              
               False- If SIP settings could not be updated.                                                            

Side Effects: Proxy Settiings Changed.                                                                                        
-----------------------------------------------------------------------------------------------------*/
function TringMeUpdateSIPSettings($cookie, $proxy, $user, $pass,&$result,$auth=""){   
	$parameters=array();
    $parameters['op']='setuser';
    $parameters['cookie']=$cookie;
    $parameters['sipproxy']=$proxy;
    $parameters['sipuser']=$user;
    $parameters['sippass']=$pass;
    
	if($auth != "") 
         $parameters['sipauth']=$auth;
    
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
 * 
Function Name: TringMeGetSIPSettings
                                                                                                  
Descripton: To Get The SIP(Session Initiated Proptocol) Setttings .
Prototype:  boolean TringMeGetSIPSettings($cookie,$result)     
                                                                                                  
Parameters:                                                                                          
           $cookie- Session Validator.                             
                                                                                             

Return Values: True- If SIP settings were updated.                                                              
               False- If SIP settings could not be updated.
-----------------------------------------------------------------------------------------------------*/
function TringMeGetSIPSettings($cookie, &$result) {
	$parameters=array();
	$parameters['op']='getsipsettings';
    $parameters['cookie']=$cookie;
	$parameters['json'] = 1;
    return TringMeAPI($parameters, $sipsettings);
}


/*----------------------------------------------------------------------------------------------------
 * 
Function Name: TringMeSetSIPCredits                                                                      
                                                                                                     
Descripton: To set SIP(Session Initiated Proptocol) credits.                                                                                                     

Prototype:  boolean TringMeSetSIPCredits($cookie,amount)     
                                                                                                     
Parameters:                                                                                          
           $cookie- Session Validator.                             
           $amount- Amount to be set.

Return Values: True- If amount is set.                                                             
               False- If amount is not set.                                                            

-----------------------------------------------------------------------------------------------------*/

function TringMeSetSIPCredits($cookie, $amount, &$result){  
    $parameters=array();
	$parameters['op']='setsipcredits';
    $parameters['amount']=$amount;
    $parameters['cookie']=$cookie;
	
    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
 
Function Name: TringMeUpdateTimezone                                                                      
                                                                                                     
Descripton: To change the timezone.

Prototype:  boolean TringMeUpdateTimezone($cookie,$result,$tmzone)     
                                                                                                     
Parameters:	$cookie- Session Validator.                             
			$tmzone- TIMEZONE

Return Values: True- If TIMEZONE is updated.                                                              
               False- If TIMEZONE could not be updated.                                                            

Side Effects: TIMEZONE Changed.                                                                                        
-----------------------------------------------------------------------------------------------------*/

function TringMeUpdateTimezone($cookie, $tmzone, &$result){  
    $parameters=array();
    $parameters['op']='setuser';
    $parameters['cookie']=$cookie;
    $parameters['tmzone']=$tmzone;

    return TringMeAPI($parameters,$result);
}

/*----------------------------------------------------------------------------------------------------
 
Function Name: TringMeUpdateSettings                                                                      
                                                                                                     
Descripton: To change the settings of user.

Prototype:  boolean TringMeUpdateSettings($cookie,$parameters)     
                                                                                                     
Parameters:	$cookie- Session Validator.                             
			$parametes- Parameters that as to be set

Return Values: True- If settings is updated.                                                              
               False- If settngs could not be updated.                                                            

Side Effects: uset settings Changed.                                                                                        
-----------------------------------------------------------------------------------------------------*/

function TringMeUpdateSettings($cookie, $parameters, &$result){   
	$parameters['op']='setuser';
    $parameters['cookie']=$cookie;

    return TringMeAPI($parameters, $result);

}


/*----------------------------------------------------------------------------------------------------
Function Name: TringMeSetPhoneCredits                                                                        
                                                                                                     
Descripton: Transfer "amount" credits in US dollars from api-key holder to user(email).                                                                             
                                                                                                     
Prototype:  boolean TringMeSetPhoneCredits($email, $amount, $result[, $private])      
                                                                                                     
Parameters:	$identifier- User email address if private account. 
			Cookie if TringMe account  
			$amount- The value of in credits US dollars to be added
			$private- Account Type. (optional, default is 0 = TringMe Account)
			$result- Contains reference code on success.
                                                                                                  
Dependencies: apikey credits                                                                               

Return Values:	True- If credits were applied to the account.
				False- If unable to apply credits.
                                                                                   
-----------------------------------------------------------------------------------------------------*/

function TringMeSetPhoneCredits($identifier, $amount, &$result, $private=0){  
    $parameters['op']='setphonecredits';
    $parameters['amount']=$amount;
    
	if($private != 0) {   
        $parameters['private']=$private;
        $parameters['email']=$identifier;
    }
    else {
        $parameters['cookie']=$identifier;    
    } 

    return TringMeAPI($parameters,$result);
}

/*-------------------------------------------------------------------------------------------------------

Function Name: TringMeResetAuthPhone                                                                        

Descripton: Authorizes the phone number.                                                                              
                                                                                   
Prototype:  boolean TringMeResetAuthPhone($result[, $cookie],$message,$phone)      

Parameters: $cookie- Session Validator.                                     
		    $messge- Message along with verification code.
			$phone-  Phone number to authenticate. 
			$result- Contains Cookie Information.

Return Values: True-  If code is sent.                                                              
			   False- If code is not sent.                                                            
-----------------------------------------------------------------------------------------------------*/

function TringMeResetAuthPhone($cookie, $message, $phone, &$result) {
	$parameters=array();
	$parameters['op']='resetauthphone';
    $parameters['cookie']=$cookie;
	$parameters['message']=$message;
	$parameters['phone']=$phone;

    return TringMeAPI($parameters, $result);

}

/*-------------------------------------------------------------------------------------------------------

Function Name: TringMeConfirmAuthPhone                                                                        

Descripton: Verifies if entered code is valid.                                                                              
                                                                                   
Prototype:  boolean TringMeGetVoiceMails($result[, $cookie, $code])      

Parameters: $cookie- Session Validator.                                     
		    $code- Verification code.
			$result- Contains Cookie Information.

Return Values: True- If VoiceMails are deleted.                                                              
			   False- If VoiceMails are not deleted.                                                            
-----------------------------------------------------------------------------------------------------*/
function TringMeConfirmAuthPhone($cookie, $code) {
	$parameters=array();
	$parameters['op']='confirmauthphone';
    $parameters['cookie']=$cookie;
	$parameters['code']=$code;

    return TringMeAPI($parameters,$result);
}


?>
